package br.unesp.rc.tcc.controller;

import java.util.List;

import javax.ws.rs.PathParam;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import br.unesp.rc.tcc.model.bean.Author;
import br.unesp.rc.tcc.services.AuthorServices;
import br.unesp.rc.tcc.services.impl.AuthorServicesImpl;


@Controller
@RequestMapping("/author")
public class AuthorController {

	//@Autowired
	//AuthorServices authorServices;
	
	@RequestMapping(value="/all", method=RequestMethod.GET)
	public List<Author> findAll() {
		AuthorServices authorServices = new AuthorServicesImpl();
		return authorServices.findAll();
	}
	
	@RequestMapping(value="/{id:[0-9]+}", method=RequestMethod.GET)
	public Author findById(@PathParam("id") final Long id) {
		AuthorServices authorServices = new AuthorServicesImpl();
		return authorServices.findById(1L);
	}
	
    /*@POST
    @Consumes({"application/xml", "application/json"})
    //@Transactional
    public Response create(Author author) {
        //entityManager.persist(author);
        //return Response.created(URI.create(entity.getAuthorId().toString())).build();
		return null;
    }

    @PUT
    @Consumes({"application/xml", "application/json"})
    //@Transactional
    public void update(Author entity) {
        //entityManager.merge(entity);
    }

    @DELETE
    @Path("{id}")
    //@Transactional
    public void delete(@PathParam("id") Integer id) {
        //Author entity = entityManager.getReference(Author.class, id);
		//entityManager.remove(entity);
        
    }

    @GET
    @Path("/{id:[0-9]+}")
    @Produces({"application/xml", "application/json"})
    //@Transactional
    public Author find(@PathParam("id") Integer id) {
        //return entityManager.find(Author.class, id);
		AuthorServices authorServices = new AuthorServicesImpl();
		return authorServices.findById(1L);
    }

    @GET
    @Produces({"application/xml", "application/json"})
    //@Transactional
    public List<Author> findAll() {
        //return find(true, -1, -1);
		AuthorServices authorServices = new AuthorServicesImpl();
		return authorServices.findAll();
    }	*/
	
}
